#!/bin/sh

#
# make postgresql stop/restart send sigint to terminate clients to postgresql
# immediately.
#

RETVAL=0

case "$1" in
  stop|force-stop)
    /opt/gitlab/embedded/bin/sv once postgresql
    /opt/gitlab/embedded/bin/sv interrupt postgresql
    RETVAL=$?
    ;;
  restart)
    /opt/gitlab/embedded/bin/sv once postgresql
    /opt/gitlab/embedded/bin/sv interrupt postgresql
    sleep 5
    /opt/gitlab/embedded/bin/sv start postgresql
    RETVAL=$?
    ;;
	*)
		/opt/gitlab/embedded/bin/sv $1 postgresql
    RETVAL=$?
esac

exit $RETVAL

